'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-10 18:21:58
'''
#
# @lc app=leetcode.cn id=1558 lang=python3
#
# [1558] 得到目标数组的最少函数调用次数
#

# @lc code=start
from typing import List
class Solution:
    def minOperations(self, nums: List[int]) -> int:
        ans = 0
        while any(nums):
            for i, v in enumerate(nums):
                if v%2:
                    ans+=1
                    nums[i]=v-1
            if not any(nums):
                continue
            ans+=1
            for i, v in enumerate(nums):
                nums[i] = v//2
        return ans
                
# @lc code=end

